home *** CD-ROM | disk | FTP | other *** search
- /*
- * File: xblockbuster.h
- * Author: Eric Van Gestel
- * X11 Support by: Mark Wedel
- * For: xblockbuster
- *
- */
-
- /* file paths are defined at the end of this file */
-
- #include <stdio.h>
- #include <pwd.h>
- /*#include <sys/file.h>
- #include <ctype.h>*/
- #include <math.h>
- #include <X11/Xlib.h>
- #include <X11/Xutil.h>
- #include <X11/Xos.h>
- #include <X11/Xatom.h>
-
-
- /*
- * #define M_PI 3.14159265358979323846
- * #define M_PI_2 1.57079632679489661923
- * #define M_PI_4 0.78539816339744830962
- */
- #define M_PI_3_4 2.35619449019234492885
- #define M_SQRT2_2 0.70710678118654752440
- #define NEAR_HORIZONTAL 0.7 /* < M_PI_4 */
-
- Display *display;
- Window win;
- GC gc, gc_erase, gc_xor,gc_color;
- XFontStruct *font_info;
- int screen_num, font_width, font_height;
-
- /*** windowing objects ***/
-
- #define BORDER 50
- #define MSG_HEIGHT font_height*2 + 4
-
- #define MAX_ROW 42
- #define MAX_COL 11
-
- /* upper left corner of brick in pixels */
- #define COL_X( col ) (col) ? (col) * 64 - 48 + BORDER : BORDER
- #define ROW_Y( row ) (row) * 16 + BORDER
-
- /* brick coordinates */
- #define X_COL( x ) ( (int)(x) - BORDER + 48 ) / 64
- #define Y_ROW( y ) ( (int)(y) - BORDER ) / 16
-
- #define STAGE_HEIGHT_IN_PIXELS ( ( MAX_ROW + 1 ) * 16 + 2 * BORDER )
- #define STAGE_WIDTH_IN_PIXELS ( ( MAX_COL - 1 ) * 64 + 2 * ( BORDER + 16 ) )
-
-
- /*** messages ***/
-
-
- #define OFFSET_BALLS 20
- #define OFFSET_SCORE 250
- #define OFFSET_SPEED 550
-
-
- /*** active objects ***/
-
- #define NO_BALL 0
- #define NE 1
- #define NW 2
- #define SW 3
- #define SE 4
-
- #ifndef FALSE
- #define FALSE 0
- #endif
- #ifndef TRUE
- #define TRUE 1
- #endif
-
- #define HORIZONTAL 1
- #define VERTICAL 2
-
- #define INIT_BALLS 3
- #define LOOP_MAX 100
-
- #define INIT_SPEED 3.0
- #define MAX_SPEED 8.0
- #define SPEED_LIMIT 12.0
- #define SPEED_INCR 0.2
- #define SPEED_INCR_2 0.1 /* SPEED_INCR / 2 */
- #define SPEED_RESOLUTION 60 /* SPEED_LIMIT / SPEED_INCR */
- #define SPEED_RESOLUTION_FACTOR 5.0 /* SPEED_RESOLUTION /
- * SPEED_LIMI
- */
-
- #define NUM_BRICK_TYPES 37
-
- /* foreground/background colors for each of the bricks - MSW */
- struct COLOR {
- unsigned long fg, bg;
- } brick_color[NUM_BRICK_TYPES+1];
-
- /* the stage is a two
- * dimensional array of
- * bricks */
-
- struct Brick {
- char code; /* Q.V. map_codes */
- short nhits;
- } stage[MAX_ROW + 1][MAX_COL + 1];
-
- #define IS_HIT_BRICK( code ) code > '0' && code <= '9'
-
- struct Ball {
- int quadrant; /* enumeration { NO_BALL, NE, NW, SW,
- * SE } */
- double angle; /* range -M_PI_4..NEAR_HORIZONTAL */
- /*
- * NW -P4|-P4 NE +NH | +NH >>>>>>+<<<<<< (gap to avoid infinite
- * horizontal bounce loops) +NH | +NH SW -P4|-P4 SE
- */
- int row, col; /* coordinates on the stage */
- double x, y; /* coordinates in pixels */
- double speed, x_speed, y_speed; /* motion per update in
- * pixels */
- /*
- * INVARIANT: x_speed == speed * cos( true_angle ) y_speed == speed *
- * sin( true_angle )
- */
- } ball1, ball2, ball3;
-
- int launch_quadrant;/* enumeration { NE, NW } */
- int launch_row, launch_col;
- double launch_x, launch_y;
- int emit_row, emit_col;
-
- #define MIN_PALLET_LENGTH 12
- #define SHORT_PALLET_LENGTH 16
- #define LONG_PALLET_LENGTH 99
- #define MAX_PALLET_LENGTH 99
- #define MAX_PALLET_HEIGHT 999
- #define PALLET_INCR 100
- #define PALLET_DENOMINATOR 20000
- #define PALLET_MIN_Y ROW_Y( MAX_ROW - 9 )
- #define PALLET_MAX_Y ROW_Y( MAX_ROW - 1 )
-
- int pallet_lengthI; /* range MIN_PALLET_LENGTH..MAX_PALLET_LENGTH */
- int pallet_heightI; /* range pallet_lengthI..MAX_PALLET_HEIGHT */
- int pallet_xI; /* range 0..STAGE_WIDTH_IN_PIXELS */
- int pallet_yI; /* range PALLET_MAX_Y+4..PALLET_MIN_Y-12 */
- int pallet_row; /* range MAX_ROW-1..MAX_ROW-9 */
- double pallet_length, pallet_height, pallet_x, pallet_y;
-
- /*
- * INVARIANT:
- * pallet_* == (double) pallet_*I;
- * pallet_width == 2 * pallet_length
- * pallet_height >= pallet_length >= ABS( excentricity )
- * => atan2( excentricity, pallet_height ) range -M_PI_4..M_PI_4
- */
- int mouse_yI; /* range 0..STAGE_HEIGHT_IN_PIXELS *//* <HC> */
-
- int nb_stages, stage_nb, balls_left, score, score_incr, nbricks, loop_nhits, pallet_modif;
- double launch_speed;
-
- #define NAME_LENGTH 20
- char stage_name[NAME_LENGTH];
-
- #define MAX_NB_STAGES 100
- int stages[MAX_NB_STAGES];
-
- struct Brick *last_busted_brick; /* NULL == none so far */
- char last_busted_code;
- int last_busted_row, last_busted_col;
-
-
-
- /*** score and stages files ***/
-
- #define PATH_LENGTH 64
-
- char *login;
- char playground[PATH_LENGTH];
-
- #ifndef STAGEDIR
- #define STAGEDIR "/usr/games/lib/blockbuster"
- #endif
-
- #define SCOREFILE "%s/scores"
- #define NB_SCORES 12
- #define USER_SCORES 3
-
- #define NB_STAGESFILE "%s/nb_stages"
- #define STAGEFILE "%s/stage%d"
- #define STAGEFILE_LENGTH PATH_LENGTH
-
- #define SAVEFILE "%s/save/%s"
- #define SAVEFILE_LENGTH PATH_LENGTH
-
- /* Timer information */
-
- #define ITIMER_DELAY 5000
-
-